<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 * Description of function
 *
 * @author admin
 */
function get_goods_by_orderid(){
    $goodslist='';
    return $goodslist;
}
function get_order_status($status){
    $statusName='';
    switch ($status) {
        case 1000:
            $statusName='已下单';
            break;
        case 2000:
            $statusName='已受理';
            break;
        case 3000:
            $statusName='交易成功';
            break;
        case -1:
            $statusName='交易取消';
            break;
        case -2:
            $statusName='交易取消';
            break;
        default:
            $statusName='交易失败';
            break;
    }
    return $statusName;
}
function get_goods_name($pid){
    
    $map = array('id'=>$pid);
    $goodsName=M('product')->where($map)->find();   
    return $goodsName['name'];
}
function get_goods_quantity($pid){   
    $map = array('id'=>$pid);
    $goodsName=M('product')->where($map)->find();   
    return $goodsName['quantity'];
}
function order_cancel($orderid){
    alert('取消');
    $map = array('orderid'=>$orderid);
    $data['status']=4000;
    $goodsName=M('order')->where($map)->save($data);   
    return $goodsName['status'];    
}

/**
 * 时间戳格式化
 * @param int $time
 * @return string 完整的时间显示
 * @author huajie <banhuajie@163.com>
 */
function time_format($time = NULL,$format='Y-m-d H:i'){
    if($time === NULL){
        return null;
    }else{
        $time = intval($time);   
        return date($format, $time);
    }
}